import * as util from './util'

export const parseTime = (time, formatter) => {
  let str = ''
  if (util.isNumber(time)) {
    let date = new Date(time)
    formatter = formatter || 'yyyy-MM-dd hh:mm'
    str = date.format(formatter)
  } else {
    str = time
  }
  return str
}

export const parseText = (title, max) => {
  const maxLength = max || max === 0 ? max : 32
  if (title && title.length > maxLength) {
    title = title.slice(0, maxLength) + '...'
  }
  return title
}
